import ElevatorPackage.Elevator;

/**
 * Created by Connor Madden.
 * User: Connor Madden
 * Date: 24/08/11
 * Time: 11:37 PM
 */
public class Program {
    private static Program ourInstance = new Program();

    public static final int START_LOCATION = 0;
    public static final int STEP_TIME = 1000;
    public static final int EXCHANGE_TIME = 3000;
    public static final int NUM_FLOORS = 5;
    private UserInterface gui;
    private Elevator elevator;

    public static Program getInstance() {
        return ourInstance;
    }

    private Program() {
    }

    public static void main(String[] args) {
        Program program = new Program();
        program.start(NUM_FLOORS, true, STEP_TIME, EXCHANGE_TIME);
    }


    public void start(int numFloors, boolean startAtZero, int stepTime, int exchangeTime) {
        if (gui != null) close();
        gui = new UserInterface();
        elevator = new Elevator(START_LOCATION, stepTime, exchangeTime);
        elevator.addObserver(gui);
        gui.go(elevator, numFloors, startAtZero);
        StoreSingle.getInstance().u = gui;
    }

    public void close() {
        StoreSingle.getInstance().u.close();
    }

}
